#pragma once

class Mouse : public Singleton<Mouse>
{
	Vertex2F m_lastPos;
	bool m_rightDown;
	bool m_leftDown;
	ui32 m_timeRDown;
	ui32 m_timeLDown;
public:

	bool LeftDown() { return m_leftDown; }
	bool RightDown() { return m_rightDown; }
	ui32 TimeLeftDown() { return m_timeLDown; }
	void ResetDownTime(bool left) { if(left) m_timeLDown = GetTickCount(); else m_timeRDown = GetTickCount(); }

	Vertex2F GetPosition() { return m_lastPos; }

	void OnMouseMove(ui32 x, ui32 y) { m_lastPos.x = (float)x; m_lastPos.y = (float)y; }
	void OnMouseDown(bool left)
	{
		if(left)
		{
			m_leftDown = true;
			m_timeLDown = GetTickCount();
		}
		else
		{
			m_rightDown = true;
			m_timeRDown = GetTickCount();
		}
	}
	void OnMouseUp(bool left)
	{
		if(left)
		{
			m_leftDown = false;
			m_timeLDown = GetTickCount();
		}
		else
		{
			m_rightDown = false;
			m_timeRDown = GetTickCount();
		}
	}
};

#define sMouse (*Mouse::GetInstance())